<template>
    <div>
      <a-button type="primary" @click="showModal">新建标签</a-button>
      <a-modal v-model:visible="visible" title="Title" @ok="handleOk">
        <template #footer>
          <a-button key="back" @click="handleCancel">返回</a-button>
          <a-button key="submit" type="primary" :loading="loading" @click="handleOk">提交</a-button>
        </template>
        <a-input v-model:value="tabs.name" placeholder="请输入标签名字" />
      </a-modal>
    </div>
  </template>
  <script>
  import { defineComponent, ref } from 'vue';
  import { get, post, tip } from "@/common";  
  export default defineComponent({
    name: "NewTabs",
    setup(props,{emit}) {
      const loading = ref(false);
      const visible = ref(false);
      const tabs=ref({
        name:"",
      });
  
      const showModal = () => {
        visible.value = true;
      };
  
      const handleOk = () => {
        loading.value = true;
        post("/post/newtabs", tabs.value).then((res) => {
         });
        
        setTimeout(() => {
          loading.value = false;
          visible.value = false;
        }, 2000);
        emit("ok");//放在setTimeout下面才能正常加载
      };
  
      const handleCancel = () => {
        visible.value = false;
      };
  
      return {
        loading,
        visible,
        showModal,
        handleOk,
        handleCancel,
        tabs,
      };
    },
  });
  </script>